home *** CD-ROM | disk | FTP | other *** search
/ Nautilus 1992 July / Nautilus-3-8 / Nautilus-3-8.bin / Tools & Utilities / Techy Stuff / Source ƒ / sky source ƒ / STARS.C < prev    next >
Encoding:
C/C++ Source or Header  |  1992-06-16  |  1.4 KB  |  87 lines

  1. #include "sky.h"
  2. #include <stdio.h>
  3.  
  4. stars()
  5. {
  6.     char starname[13];
  7.     register i;
  8.     double temp1;
  9.     FILE *f;
  10.  
  11.     starname[12] = 0;
  12.     object = starname;
  13.  
  14.  
  15. /*
  16.  *    read epoch of star table
  17.  *    and convert to internal format
  18.  *    epoch 1900.0 is J.D. 2415020.313
  19.  */
  20.  
  21.     f = fopen(startab, "r");
  22.     if(f == NULL) {
  23.         printf("%s?\n", startab);
  24.         return;
  25.     }
  26.     rline(f);
  27.     epoch = atof(line);
  28.     epoch = (epoch-1900.0) * 365.2422 + 0.313;
  29.  
  30. /*
  31.  *    read mean places of stars at epoch of star table
  32.  */
  33.  
  34. loop:
  35.     if(rline(f)) {
  36.         fclose(f);
  37.         return;
  38.     }
  39.     for(i=0;i<12;i++){
  40.         starname[i] = line[i];
  41.     }
  42.     agc = (long)atof(line+12);
  43.     rah = atof(line+17);
  44.     ram = atof(line+20);
  45.     ras = atof(line+23);
  46.     da = atof(line+30);
  47.     dday = atof(line+37);
  48.     dmin = atof(line+41);
  49.     dsec = atof(line+44);
  50.     dd = atof(line+50);
  51.     px = atof(line+57);
  52.     mag = atof(line+64);
  53.     const = (int)atof(line+70);
  54.  
  55. /*
  56.  *    convert rt ascension and declination to internal format
  57.  */
  58.  
  59.     alpha = rah + ram/60. + ras/3600.;
  60.  
  61.  
  62.     delta = fabs(dday) + dmin/60. + dsec/3600.;
  63.     if(dday < 0.)
  64.         delta = -delta;
  65.     alpha *= 15.*radian;
  66.     delta *= radian;
  67.  
  68.     star();
  69.     output();
  70. /*
  71.  *    Check for occultation.
  72.  */
  73.  
  74.     if(!((flags&GEO)||(flags&HELIO))){
  75.         temp1 = sin(decl2)*sin(moonde) + cos(decl2)*cos(moonde)*cos(ra-moonra);
  76.         temp1 = atan2(sqrt(1.-temp1*temp1),temp1)/radsec;
  77.         temp1 = temp1/moonsd;
  78.         if(temp1 <= 1.0){
  79.             printf("Occultation: Dist. = %.4f\n", temp1);
  80.         }else if(temp1 <= 1.2){
  81.             printf("Near occultation: Dist. = %.4f\n", temp1);
  82.         }
  83.     }
  84.  
  85.     goto loop;
  86. }
  87.